# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer:
pkgname=tachyon
pkgver=0.99_beta6
pkgrel=1
pkgdesc="Multithreaded ray tracing software"
url="https://web.archive.org/web/20220728040107/http://jedi.ks.uiuc.edu/~johns/raytracer"
arch="all"
license="BSD-3-Clause"
makedepends="jpeg-dev libpng-dev"
source="https://archive.org/download/tachyon_${pkgver//_beta/b}dsx.orig.tar.xz/tachyon_${pkgver//_beta/~b}%2Bdsx.orig.tar.xz"
subpackages="$pkgname-scenes:_scenes"
builddir="$srcdir/$pkgname-${pkgver//_beta/~b}+dsx.orig/unix"

case "$CARCH" in
	armhf|armv7|x86) _target=linux-thr;;
	*) _target=linux-64-thr;;
esac

build() {
	sed -i -e "s/-m32 //" -e "s/-m64 //" Make-arch
	make \
		USEJPEG="-DUSEJPEG" \
		JPEGLIB="$(pkgconf --libs libjpeg)" \
		USEPNG="-DUSEPNG" \
		PNGLIB="$(pkgconf --libs libpng)" \
		"$_target"
}

check() {
	../compile/"$_target"/tachyon ../scenes/island.dat
}

package() {
	cd ../compile/"$_target"
	install -Dm755 tachyon "$pkgdir"/usr/bin/tachyon
	install -d "$pkgdir"/usr/share/tachyon
	cp -r ../../scenes "$pkgdir"/usr/share/tachyon/scenes
}

_scenes() {
	pkgdesc="Example scenes for processing by tachyon"
	arch="noarch"
	amove usr/share/tachyon/scenes
}

sha512sums="
aac052adcaaf1d44d7c087b9f11af6eb2ddea2df2848cf0d9a030993db6a544466ca06a9139f81f30cf150e616d7c46f5e8f56d4be54128c932b0228537fc4d4  tachyon_0.99~b6%2Bdsx.orig.tar.xz
"
